function [ output_args ] = test_cow_body_detection_by_horse_model( )

name            =    'HORSE';
cachedir        =    'cache/';
% -----------------change these two lines----------------------
test_dir        =    'voc_cow_db/Cow_ObjCut';   %
save_name       =    'cow_objcut';   %'cow_test';
% -------------------------------------------------------------
K               =    [3   3 3 3 3   3 3 5 5            3  5        5 5 5     ];      % cluster Number 
convell_index   =    [1:5 11 10 12 13 14 6]; %[1:5 11 10 12 13 14 9 8 7 6 1];
validate_index  =    [7 8 9]; 
verbos          =    1;

suffix = num2str(K')'; 

cls = [name '_final_' num2str(K')'];
load([cachedir cls],'model');


files = dir([test_dir '/*.png']);
test =  [];
for i = 1:length(files),
  test(i).im = [test_dir '/' files(i).name];
end     


if(~exist([cachedir save_name '_boxes_' suffix '.mat'], 'file'))
    model.thresh   = min(model.thresh,-2); 
    [boxes points] = testmodel(save_name, model, test,suffix);
end    


load([cachedir  save_name '_boxes_' suffix '.mat']);

for n= 1:length(points)  
    im    =   imread(test(n).im);
    disp(['process: ' num2str(n) test(n).im]);
    siz   =   size(im);      siz(3) = [];
    im_center   =   siz/2 + 0.5;
    
    inst_s      =   points{n}(1,[2*convell_index-1;  2*convell_index]); 
    %inst_v      =   points{n}(1,[2*validate_index-1; 2*validate_index]);
    
        if verbos >0
     figure(1);  showConvell(im, points{n}(1,:), convell_index);               
        end
    
end




function  showConvell(im, points, index)
    num =   length(points);
    xi = 2*[index index(1)];
    imagesc(im); axis image; axis off;  hold on; 
    plot(points(xi-1), points(xi),'g-', 'lineWidth', 2);
    plot(points(xi-1), points(xi),'r*', 'lineWidth', 3);   
    hold off;    drawnow;
